import json

from flask import Blueprint
from flask import render_template

from web.system.login_page import classic_login_page_build

index_bp = Blueprint("index", __name__)


@index_bp.route("/login")
def login():
    login_api = "post:/api/login"
    login_page = classic_login_page_build(login_api)
    return render_template(
        "login.html",
        content=json.dumps(login_page, indent=2, ensure_ascii=False),
    )


@index_bp.route("/main")
def main():
    return render_template(
        # 渲染模板语言
        "main.html",
        version="amis@3.6.3",
        min=""
    )


@index_bp.route("/")
@index_bp.route("/demo")
def demo_amis():
    return render_template(
        "demo_amis.html",
        version="amis@3.6.3",
        min=""
    )


@index_bp.route("/test")
def test():
    list1 = list(range(10))
    my_list = [
        {"id": 1, "value": "我爱工作!!!!!!!!!!!"},
        {"id": 2, "value": "工作使人快乐"},
        {"id": 3, "value": "沉迷于工作无法自拔"},
        {"id": 4, "value": "日渐消瘦"},
        {"id": 5, "value": "以梦为马，越骑越傻"},
    ]
    return render_template(
        # 渲染模板语言
        "test.html",
        title="hello world",
        list2=list1,
        my_list=my_list,
    )
